from flask import Flask, render_template, request
from werkzeug.utils import secure_filename
import tensorflow  as tf
from nets.test import app_predict
app = Flask(__name__)

model = tf.keras.models.load_model("model/cnn.h5")

@app.route('/upload')
def upload():
    return render_template('upload.html')


@app.route('/uploader', methods=['GET', 'POST'])
def upload_file():
    if request.method == 'POST':
        f = request.files['file']
        f.save(secure_filename(f.filename))
        label = app_predict(secure_filename(f.filename), model)

        #return 'file uploaded successfully'
        return label

if __name__ == '__main__':
    app.run(debug=True)

